package edu.wpi.cs509.representation;

import java.util.logging.Logger;


/**
 * ActionRemove is a specific type of action whereby the piece is
 * moved from an on-board location to the off-board location graveyard.
 * This typically happens when a piece loses a battle, but also
 * might happen during the board setup phase.
 * @author cwinsor
 */
public class ActionRemove extends ActionBaseClass {


	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Constructor
	 * @param name - gives this action a name
	 */
	public ActionRemove(String name, Gameboard gameboard,
			PlayerPiece pce, Location loc) {

		super(name, gameboard, pce, loc);
	}

	/**
	 * doCheck - check the move for legality
	 */
	protected void doStrategoRulesCheck() throws ActionNotLegalException {
		
		// debug message
		Logger.getLogger("global").info("here");

		// check the destination location is the boneyard
		if (!isBoneyardDestination()) {
			setErrMessage("ActionRemove - the destination was not the boneyard");
			throw new ActionNotLegalException();
		}		
	}


	/**
	 * doExecute - perform the action
	 * will throw an exception if the move is illegal	
	 */
	protected void doExecute() throws ActionNotLegalException, ActionEndOfGameException  {

		// debug message
		Logger.getLogger("global").info("here");
		
		// execute the move (generic)
		super.doExecute();

		return;
	}

}
